package com.ntd.util;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class UtilSys {

    private static Robot robot;
    private static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    private static int winWidth = 500;
    private static int winHeight = 500;

    static {
        try {
            robot = new Robot();
            winWidth = (int) screenSize.getWidth();
            winHeight = (int) screenSize.getHeight();
        } catch (AWTException e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取屏幕截图
     * @return
     * @throws AWTException
     * @throws IOException
     */
    public static BufferedImage getScreenCapture() {
        return robot.createScreenCapture(new Rectangle(winWidth, winHeight));
    }
}
